package cn.ffcs.uec.payroll.component;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zul.Div;

import cn.ffcs.uec.payroll.component.bean.UecPayRollEditExtBean;
import cn.ffcs.uec.payroll.model.UecPayRoll;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.ListboxUtils;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.vo.NodeVo;
import lombok.Getter;
import lombok.Setter;

@Controller
@Scope("prototype")
public class UecPayRollEditExt extends Div implements IdSpace {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6487871788980086081L;
	/**
	 * 对应页面上的bean
	 */
	@Getter
	private UecPayRollEditExtBean bean = new UecPayRollEditExtBean();
	/**
	 * 人员政治面貌实体
	 */
	private UecPayRoll uecPayRoll;

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public UecPayRollEditExt() {
		Executions.createComponents("/pages_nmg/uec_payroll/comp/uec_payroll_edit_ext.zul",
				this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');
		

	}

	/**
	 * 初始化
	 */
	public void onCreate() {
		// this.setButtonValid(false, false);
		bindCombobox();
	}

	/**
	 * 绑定combobox
	 */
	private void bindCombobox() {
		List<NodeVo> nodeVoIsList = new ArrayList<NodeVo>();
		String[][] is = {{"Y", "是"}, {"N", "否"}};
		for (int i = 0; i < is.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(is[i][j]);
				nodeVo.setName(is[i][j + 1]);
			}
			nodeVoIsList.add(nodeVo);
		}
		//是否审批通过
		ListboxUtils.rendererForEdit(bean.getIsapproved(),
				nodeVoIsList);
		
	}
	/**
	 * 清除变量
	 */
	public void clearVariable() {
		uecPayRoll = null;
	}

	/**
	 * 查询
	 */
	public void onQueryUecPayRollList() {
		if (null != uecPayRoll) {
			PubUtil.fillBeanFromPo(uecPayRoll, bean);
		}
	}
	
}
